from django.db import models
from user.models import CustomUser
from main.models import Anime

# Create your models here.


class Collect(models.Model):
    user = models.ForeignKey(verbose_name="用户", to=CustomUser, on_delete=models.CASCADE)
    anime = models.ForeignKey(verbose_name="番剧", to=Anime, on_delete=models.CASCADE)
    time = models.DateTimeField(verbose_name="收藏时间", auto_now_add=True)

    def __str__(self):
        return f"{self.user.username}收藏了{self.anime.title}"

    class Meta:
        verbose_name = "收藏"
        verbose_name_plural = "收藏"
        unique_together = [("user", "anime")]
